package com.bean.activiti.activiti.entity.manager;

import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.interceptor.Session;
import org.activiti.engine.impl.interceptor.SessionFactory;
import org.activiti.engine.impl.persistence.entity.UserEntityManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Gavin Lee
 * @version 1.0
 * @date 2020-9-11 9:23
 * @desc
 */
@Service
public class CustomUserEntityManagerFactory  implements SessionFactory {
    // 使用自定义的User管理类
    @Autowired
    private CustomUserEntityManager customUserEntityManager;

    @Override
    @Autowired
    public Class<?> getSessionType() {
        //注意此处也必须为Activiti原生类
        return UserEntityManager.class;
    }

    @Override
    public Session openSession(CommandContext var1) {
        return customUserEntityManager;
    }

    @Autowired
    public void setCustomUserEntityManager(CustomUserEntityManager customUserEntityManager) {
        this.customUserEntityManager = customUserEntityManager;
    }
}
